<template is="msgItem1">
	<view class="content">
		
		<view class="withdrawal-content">
			<view class="title">提现金额</view>
			<view class="number-val">
				<input type="digit" v-model="money">
			</view>
			<view class="withdrawal-y">可提现金额{{money_number}}元，<view class="whole" @click="wholemoney()">全部提现</view></view>
			<view class="withdrawal-button" @click="tixian">提现</view>
		</view>
		
		<view class="withdrawal-bottom">
			<view class="withdrawal-record" @click="tixianjilv">提现记录</view>
			<view>|</view>
			<view class="withdrawal-po" @click="gotohelp">相关问题</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				money_number:"180.15",
				money:"",
				token:"",
				
				w_service_charge:"",//服务费
				min_amount:"",//最小提现
				max_amount:""//最大提现
			};
		},
		
		onShow() {
			var _self = this
			
			const value = uni.getStorageSync('userinfo');
			if (value) {
				_self.token = value.token
			}
			uni.request({
			    url: _self.$url + '/api/user/getUserMoney', 
				method:"post",
			    data: {
			       
			    },
				header: {
					'token': _self.token 
				},
			    success: (res) => {
					_self.money_number = res.data.result
			    }
			});
			
		},
		
		onLoad() {
			var _self = this
			try {
			    const value = uni.getStorageSync('userinfo');
			    if (value) {
					_self.token = value.token
			    }
			} catch (e) {
			    // error
			}
			uni.request({
			    url: _self.$url + '/api/withdrawals/getWserviceConfig', 
				method:"post",
			    data: {
			       
			    },
				header: {
					'token': _self.token 
				},
			    success: (res) => {
					_self.w_service_charge = res.data.result.w_service_charge
					_self.min_amount = res.data.result.min_amount
					_self.max_amount = res.data.result.max_amount
			    }
			});
		},
		methods: {
			wholemoney(){
				this.money = this.money_number
			},
			tixian(){
				var _self = this
				uni.request({
				    url: _self.$url + '/api/withdrawals/applicationCash', 
					method:"post",
				    data: {
				       money:_self.money
				    },
					header: {
						'token': _self.token 
					},
				    success: (res) => {
						uni.showToast({
						    title: res.data.msg,
						    duration: 3000,
							icon:"none",
							mask:true,
							success() {
								uni.switchTab({
								    url: '/pages/index/usercontent'
								});
							}
						});
				    }
				});
			},//提现
			tixianjilv(){
				uni.navigateTo({
				    url: '/pages/index/withdrawalSuccess',
				    animationType: 'pop-in',
				    animationDuration: 200
				});
			},
			gotohelp(){
				uni.navigateTo({
				    url: '/pages/index/explain',
				    animationType: 'pop-in',
				    animationDuration: 200
				});
			}
		}
	}
</script>

<style lang="scss">
	body{
		background: #fafafa;
		font-size: 14px;
	}
	view{
		box-sizing: border-box;
	}
	.withdrawal-content{
		background: #fff;
		padding:30rpx;
		border-radius: 5px;
		width: 90%;
		margin:40rpx auto;
		.number-val{
			width: 100%;
			margin:20rpx 0;
			input{
				border-bottom:1px solid #DDDDDD;
				padding:20rpx 70rpx;
				font-size: 28px;
				font-weight: bold;
				height: 80rpx;
				background: url(../../static/number.png) no-repeat center left;
				background-size: 8%;
			}
		}
		.withdrawal-y{
			color: #999999;
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			align-items: center;
			.whole{
				color:#F4313E;
			}
		}
		.withdrawal-button{
			width: 100%;
			padding:20rpx 0;
			text-align: center;
			background: #F4313E;
			border-radius: 5px;
			color:#fff;
			margin-top:25rpx;
		}
	}
	
	.withdrawal-bottom{
		position: absolute;
		bottom:20rpx;
		width: 100%;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		.withdrawal-record,.withdrawal-po{
			margin:0 50rpx;
		}
	}
</style>
